﻿<Window x:Class="eDirectory.WPF.Agenda.View.AgendaView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:tk="http://schemas.microsoft.com/wpf/2008/toolkit"        
        Title="Customer View" Height="400" Width="400" WindowStartupLocation="CenterScreen">
    <Grid Name="MainLayout">
        <Grid.RowDefinitions>
            <RowDefinition Name="CustomerSection" />
            <RowDefinition Name="CollectionSection" />
        </Grid.RowDefinitions>
        <GroupBox Header="List of Customers" Margin ="5" Padding="5" Grid.Row="0">
            <Grid Name="ListOfCustomers">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <tk:DataGrid Grid.Row="0" Name="CustomerGrid" 
                             AutoGenerateColumns="False" 
                             CanUserAddRows="False" 
                             VerticalScrollBarVisibility="Visible"
                             CanUserReorderColumns="False"
                             VerticalAlignment="Top"
                             ItemsSource="{Binding Path=Model.CustomerList}"
                             SelectedItem="{Binding Path=Model.SelectedCustomer, Mode=TwoWay}">
                    <tk:DataGrid.Columns>
                        <tk:DataGridTextColumn Header="Customer Id" Binding="{Binding Path=Id, Mode=OneWay}"/>
                        <tk:DataGridTextColumn Header="First Name" Binding="{Binding Path=FirstName, Mode=OneWay}"/>
                        <tk:DataGridTextColumn Header="Last Name" Binding="{Binding Path=LastName, Mode=OneWay}"/>
                        <tk:DataGridTextColumn Header="Telephone" Binding="{Binding Path=Telephone, Mode=OneWay}"/>
                    </tk:DataGrid.Columns>
                </tk:DataGrid>
                <StackPanel Grid.Row="1" Margin="5"  Orientation="Horizontal" HorizontalAlignment="Center">
                    <Button Padding="5" Margin="5" Command="{Binding CreateCustomerCommand}">Add New</Button>
                    <Button Padding="5" Margin="5" Command="{Binding UpdateCustomerCommand}">Edit</Button>
                    <Button Padding="5" Margin="5" Command="{Binding DeleteCustomerCommand}">Delete</Button>
                    <Button Padding="5" Margin="5" Command="{Binding RefreshCommand}">Refresh</Button>
                </StackPanel>
                
            </Grid>
        </GroupBox>

        <GroupBox Header="Customer's Addresses" Margin="5" Padding="5" Grid.Row="1" IsEnabled="{Binding Path=Model.IsAdressEnabled}">
            <Grid Name="ListOfAddresses">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <tk:DataGrid Grid.Row="0" Name="AddressGrid" 
                             AutoGenerateColumns="False" 
                             CanUserAddRows="False" 
                             VerticalScrollBarVisibility="Visible"
                             CanUserReorderColumns="False"
                             VerticalAlignment="Top"
                             ItemsSource="{Binding Path=Model.SelectedCustomer.Addresses}"
                             SelectedItem="{Binding Path=Model.SelectedAddress, Mode=TwoWay}">
                    <tk:DataGrid.Columns>
                        <tk:DataGridTextColumn Header="Street" Binding="{Binding Path=Street, Mode=OneWay}"/>
                        <tk:DataGridTextColumn Header="City" Binding="{Binding Path=City, Mode=OneWay}"/>
                        <tk:DataGridTextColumn Header="Post Code" Binding="{Binding Path=PostCode, Mode=OneWay}"/>
                        <tk:DataGridTextColumn Header="Country" Binding="{Binding Path=Country, Mode=OneWay}"/>
                    </tk:DataGrid.Columns>
                </tk:DataGrid>
                <StackPanel Grid.Row="1" Margin="5"  Orientation="Horizontal" HorizontalAlignment="Center">
                    <Button Padding="5" Margin="5" Command="{Binding CreateAddressCommand}">Add New</Button>
                    <Button Padding="5" Margin="5" Command="{Binding UpdateAddressCommand}">Edit</Button>
                    <Button Padding="5" Margin="5" Command="{Binding DeleteAddressCommand}">Delete</Button>
                    <Button Padding="5" Margin="5" Command="{Binding RefreshCommand}">Refresh</Button>
                </StackPanel>

            </Grid>
        </GroupBox>
    </Grid>
</Window>
    